import Page
from Page import Yomi
from Base.Base import Base
from selenium.webdriver.common.by import By


class YomiQuitToastPage(Base):
    """
    语音训练退出弹窗

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 退出标题
        self.quit_title_text = (By.XPATH, Yomi.RESOURCE_ID.format("confirm_dialog_title"))

        # 退出标题
        self.quit_content_text = (By.XPATH, Yomi.RESOURCE_ID.format("confirm_dialog_content"))

        # 确认按钮
        self.quit_ok_btn = (By.XPATH, Yomi.RESOURCE_ID.format("btn_confirm_sure"))

        # 取消按钮
        self.quit_no_btn = (By.XPATH, Yomi.RESOURCE_ID.format("btn_confirm_cancel"))

    def get_title(self):
        """
        获取退出标题

        :return:获取元素
        """
        return self.find_element_o(self.quit_title_text)

    def get_content(self):
        """
        获取退出内容

        :return:获取元素
        """
        return self.find_element_o(self.quit_content_text)

    def click_ok(self):
        """
        点击确认按钮

        :return:None
        """
        self.click_element(self.quit_ok_btn)

    def click_no(self):
        """
        点击取消按钮

        :return:None
        """
        self.click_element(self.quit_no_btn)

    def is_display_yomi_car_quit(self):
        """
        查看是否进入退出弹窗

        :return:
        """
        return self.is_display(self.quit_title_text)
